package ch1100;

import java.awt.Button;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;



public class SwingTest implements ActionListener{
	static JFrame myFrame;
	static JTextArea textArea;
	static JButton button;
	public SwingTest() {
		
	}
	public static void main(String[] args) {
		 myFrame=new JFrame();
		myFrame.setBackground(Color.black);
		//myFrame.setSize(200,300);
		myFrame.setBounds(100,100, 1500, 1600);
		myFrame.setLayout(new GridLayout(3,2));
		 textArea=new JTextArea("test");
		textArea.setBounds(150, 150, 20, 5);
		
		myFrame.add(textArea,"1");
		 button=new JButton("click here");
		button.setBounds(700,700,20,5);
		button.addActionListener(new SwingTest());
		myFrame.add(button,"3");
		
		myFrame.setVisible(true);

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO 自动生成的方法存根
		//if(e.getSource()==button)
			textArea.setText("你 have clicked this button!");
		 
			
			
	}

}
